import { IDispose } from "../../../../../com/gengine/core/IDispose";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { ObjectPool } from "../../../../../com/gengine/utils/pools/ObjectPool";
import { Vector } from "../../../../../__AS3__/vec/Vector";
import { _normalHeight } from "../../../../../this/_normalHeight";
type int = number;
//class ChatItem
    
    export  class ChatItem /* flash.display.Sprite */ implements IDispose
    {
        constructor()
        {
            
            this._groupVector = new Vector.<flash.text.engine.ContentElement>();
            return;
        }

        public init(arg1: Vector.<flash.text.engine.ContentElement>=null, arg2: int=260, arg3: number=21): void
        {
            this._lineWidth = arg2;
            this._groupVector = arg1;
            this._lineHeight = arg3;
            this.mouseEnabled = false;
            this.createChildren();
            return;
        }

        public createChildren(): void
        {
            if (!this._groupVector || this._groupVector.length == 0) 
            {
                this.clear();
                return;
            }
            var loc1=new Object /* flash.text.engine.GroupElement */(this._groupVector);
            this._textBlock = new Object /* flash.text.engine.TextBlock */();
            this._textBlock.content = loc1;
            this.createTextLines(this._textBlock);
            return;
        }

        /* internal  */createTextLines(arg1: Object /* flash.text.engine.TextBlock */): void
        {
            this._totleHeight = 0;
            var loc1=true;
            var loc2=arg1.createTextLine(null, this._lineWidth);
            while (loc2) 
            {
                loc2.filters = [FilterConst.glowFilter];
                var loc3;
                var loc4=((loc3 = this)._col + 1);
                loc3._col = loc4;
                this.addChild(loc2);
                loc2.mouseEnabled = false;
                loc2.doubleClickEnabled = false;
                loc2.x = this._col <= 1 ? 0 : 5;
                this._totleHeight = this._totleHeight + this.getLineHeight(loc2);
                loc2.y = this._totleHeight + this.getTextLineYOffect(loc2);
                if (loc1) 
                {
                    this._firstLineHeight = this.getLineHeight(loc2);
                    loc1 = false;
                }
                loc2 = arg1.createTextLine(loc2, this._lineWidth);
            }
            return;
        }

        /* internal  */isHaveFace(arg1: Object /* flash.text.engine.TextLine */): Boolean
        {
            return arg1.height > 20;
        }

        /* internal  */isHaveVIPFace(arg1: Object /* flash.text.engine.TextLine */): Boolean
        {
            return arg1.height > 30;
        }

        /* internal  */getLineHeight(arg1: Object /* flash.text.engine.TextLine */): number
        {
            return this.isHaveVIPFace(arg1) ? this._vipFaceHeigth : this.isHaveFace(arg1) ? this._faceHeigth : _normalHeight;
        }

        /* internal  */getTextLineYOffect(arg1: Object /* flash.text.engine.TextLine */): number
        {
            return this.isHaveFace(arg1) ? -6 : -3;
        }

        public getFirstLineHeight(): number
        {
            return this._firstLineHeight;
        }

        public set groupVector(arg1: Vector.<flash.text.engine.ContentElement>)
        {
            this._groupVector = arg1;
            this.clear();
            this.createChildren();
            return;
        }

        /* internal  */clear(): void
        {
            var loc1=null;
            var loc2=(this.numChildren - 1);
            while (loc2 >= 0) 
            {
                loc1 = this.getChildAt(loc2);
                this.removeChildAt(loc2);
                --loc2;
            }
            this._totleHeight = 0;
            this._col = 0;
            return;
        }

        public get col(): int
        {
            return this._col;
        }

        public /* override */ get height(): number
        {
            return this._totleHeight;
        }

        public get textBlock(): Object /* flash.text.engine.TextBlock */
        {
            return this._textBlock;
        }

        public /* override */ addChild(arg1: Object /* flash.display.DisplayObject */): Object /* flash.display.DisplayObject */
        {
            return super.addChild(arg1);
        }

        public get lineWidth(): number
        {
            return this._lineWidth;
        }

        public set lineWidth(arg1: number)
        {
            this._lineWidth = arg1;
            return;
        }

        public get lineHeight(): number
        {
            return this._lineHeight;
        }

        public set lineHeight(arg1: number)
        {
            this._lineHeight = arg1;
            return;
        }

        public dispose(arg1: Boolean=true): void
        {
            this.clear();
            x = 0;
            y = 0;
            this._groupVector = null;
            this._textBlock = null;
            this._lineWidth = 260;
            this._lineHeight = 21;
            this._normalHeight = 19;
            this._faceHeigth = 24;
            this._firstLineHeight = 18;
            ObjectPool.disposeObject(this);
            return;
        }

        /* internal */ /* var */_lineWidth: number;

        /* internal */ /* var */_lineHeight: number;

        /* internal */ /* var */_textBlock: Object /* flash.text.engine.TextBlock */;

        /* internal */ /* var */_groupVector: Vector.<flash.text.engine.ContentElement>;

        /* internal */ /* var */_normalHeight: number=19;

        /* internal */ /* var */_faceHeigth: number=24;

        /* internal */ /* var */_vipFaceHeigth: number=48;

        /* internal */ /* var */_firstLineHeight: number=18;

        /* internal */ /* var */_totleHeight: int=0;

        /* internal */ /* var */_col: int=0;
    }
